package com.ruoyi.business.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.CzVideo;
import com.ruoyi.business.service.ICzVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 视频记录Controller
 * 
 * @author ruoyi
 * @date 2022-01-09
 */
@Api(tags = "视频记录")
@RestController
@RequestMapping("/business/video")
public class CzVideoController extends BaseController
{
    @Autowired
    private ICzVideoService czVideoService;

    /**
     * 查询视频记录列表
     */
    @ApiOperation(value = "查询视频记录列表")
    @PreAuthorize("@ss.hasPermi('business:video:list')")
    @GetMapping("/list")
    public TableDataInfo list(CzVideo czVideo)
    {
        startPage();
        List<CzVideo> list = czVideoService.selectCzVideoList(czVideo);
        return getDataTable(list);
    }

    /**
     * 导出视频记录列表
     */
    @ApiOperation(value = "导出视频记录列表")
    @PreAuthorize("@ss.hasPermi('business:video:export')")
    @Log(title = "视频记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CzVideo czVideo)
    {
        List<CzVideo> list = czVideoService.selectCzVideoList(czVideo);
        ExcelUtil<CzVideo> util = new ExcelUtil<CzVideo>(CzVideo.class);
        util.exportExcel(response, list, "视频记录数据");
    }

    /**
     * 获取视频记录详细信息
     */
    @ApiOperation(value = "获取视频记录详细信息")
    @PreAuthorize("@ss.hasPermi('business:video:query')")
    @GetMapping(value = "/{videoId}")
    public AjaxResult getInfo(@PathVariable("videoId") String videoId)
    {
        return AjaxResult.success(czVideoService.selectCzVideoByVideoId(videoId));
    }

    /**
     * 新增视频记录
     */
    @ApiOperation(value = "新增视频记录")
    @PreAuthorize("@ss.hasPermi('business:video:add')")
    @Log(title = "视频记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CzVideo czVideo)
    {
        return toAjax(czVideoService.insertCzVideo(czVideo));
    }

    /**
     * 修改视频记录
     */
    @ApiOperation(value = "修改视频记录")
    @PreAuthorize("@ss.hasPermi('business:video:edit')")
    @Log(title = "视频记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CzVideo czVideo)
    {
        return toAjax(czVideoService.updateCzVideo(czVideo));
    }

    /**
     * 删除视频记录
     */
    @ApiOperation(value = "删除视频记录")
    @PreAuthorize("@ss.hasPermi('business:video:remove')")
    @Log(title = "视频记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{videoIds}")
    public AjaxResult remove(@PathVariable String[] videoIds)
    {
        return toAjax(czVideoService.deleteCzVideoByVideoIds(videoIds));
    }
}
